@layout("/common/_container.html",{js:["/assets/Product/shiProductList/shiProductList_add.js"]}){

<script src="http://libs.baidu.com/jquery/2.0.0/jquery.js"></script>
<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>
<script src="../assets/Product/shiProductList/shiProductList_add.js"></script>




<div class="layui-body-header">
    <span class="layui-body-header-title">添加</span>
</div>

<div class="layui-fluid " style="">
    <div class="layui-card">
        <div class="layui-card-body">
            <form id="shiProductListForm" action="http://localhost:8086/shiProductList/addItem" lay-filter="shiProductListForm" class="layui-form model-form" style="max-width: 700px;margin: 40px auto;">
                <input name="productId" type="hidden"/>
                <div class="layui-form-item">
                    <label class="layui-form-label">产品名称<span style="color: red;">*</span></label>
                    <div class="layui-input-block">
                        <input id="productName" name="productName" placeholder="请输入产品名称" type="text" class="layui-input" lay-verify="required" required/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">产品编码<span style="color: red;">*</span></label>
                    <div class="layui-input-block">
                        <input id="productCode" name="productCode" placeholder="请输入产品编码" type="text" class="layui-input" lay-verify="required" required/>
                    </div>
                </div>


                <div class="layui-form-item">
                    <label class="layui-form-label">产品分类 <span style="color: red;">*</span></label>
                    <div class="layui-input-block">
                        <select name="productCategory" id="productCategorys" lay-verify="required" lay-filter="period" style="width:580px;height:36px;position: absolute;top: 0; display: block !important;">
                            <option value="1">一级按摩椅</option>
                            <option value="2">二级按摩椅</option>
                            <option value="3">三级按摩椅</option>
                            <option value="4">四级按摩椅</option>
                            <option value="5">五级按摩椅</option>
                        </select>
                    </div>
                </div>



                <div class="layui-form-item">
                    <label class="layui-form-label">产品型号 <span style="color: red;">*</span></label>
                    <div class="layui-input-block">
                        <input id="productModelss" name="productModels" placeholder="请选择产品型号" type="text" class="layui-input" lay-verify="required" required/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">顾客型号 <span style="color: red;">*</span></label>
                    <div class="layui-input-block">
                        <input id="customerModelss" name="customerModels" placeholder="请选择顾客型号" type="text" class="layui-input" lay-verify="required" required/>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">产品颜色 <span style="color: red;">*</span></label>
                    <div class="layui-input-inline">
                        <select name="productColor" id="productColors" lay-verify="required" lay-filter="period" style="width:580px;height:36px;position: absolute;top: 0; display: block !important;">

                        </select>
                    </div>
                </div>


                <div class="layui-form-item">
                    <label class="layui-form-label">产品色号 <span style="color: red;">*</span></label>
                    <div class="layui-input-block">
                        <select name="productColorNumber" id="productColorNumbers" lay-verify="required" lay-filter="period" style="width:580px;height:36px;position: absolute;top: 0; display: block !important;">

                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">产品材质 <span style="color: red;">*</span></label>
                    <div class="layui-input-block">
                        <select name="productMaterial" id="productMaterials" lay-verify="required" lay-filter="period" style="width:580px;height:36px;position: absolute;top: 0; display: block !important;">

                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">产品单位 <span style="color: red;">*</span></label>
                    <div class="layui-input-block">
                        <select name="productUnit" id="productUnits" lay-verify="required" lay-filter="period" style="width:580px;height:36px;position: absolute;top: 0; display: block !important;">

                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">经销商等级 <span style="color: red;">*</span></label>
                    <div class="layui-input-block">
                        <select name="gradeName" id="gradeName" lay-verify="required" lay-filter="period" style="width:580px;height:36px;position: absolute;top: 0; display: block !important;">

                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">产品价格 <span style="color: red;">*</span></label>
                    <div class="layui-input-block">
                        <select name="pricePrice" id="pricePrices" lay-verify="required" lay-filter="period" style="width:580px;height:36px;position: absolute;top: 0; display: block !important;">

                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">包装尺寸 <span style="color: red;">*</span></label>
                    <div class="layui-input-block">
                        <input id="productPackageSizes" name="productPackageSize" placeholder="请输入包装尺寸" type="text" class="layui-input" lay-verify="required" required/>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">单台件数 <span style="color: red;">*</span></label>
                    <div class="layui-input-block">
                        <input id="productNumberOfUnitsPerUnitss" name="productNumberOfUnitsPerUnits" placeholder="请输入单台件数" type="text" class="layui-input" lay-verify="required" required/>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">大单位 <span style="color: red;">*</span></label>
                    <div class="layui-input-block">
                        <input id="productLargeUnits" name="productLargeUnit" placeholder="请输入大单位" type="text" class="layui-input" lay-verify="required" required/>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">单台体积 <span style="color: red;">*</span></label>
                    <div class="layui-input-block">
                        <input id="productSingleUnitVolumes" name="productSingleUnitVolume" placeholder="请输入单台体积" type="text" class="layui-input" lay-verify="required" required/>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">单台毛重 <span style="color: red;">*</span></label>
                    <div class="layui-input-block">
                        <input id="productGrossWeightPerUnits" name="productGrossWeightPerUnit" placeholder="请输入单台毛重" type="text" class="layui-input" lay-verify="required" required/>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">上市时间 <span style="color: red;">*</span></label>
                    <div class="layui-input-block">
                        <input id="productTimeToMarkets" name="productTimeToMarket" placeholder="请输入上市时间" type="text" class="layui-input" lay-verify="required" required/>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">产品渠道 <span style="color: red;">*</span></label>
                    <div class="layui-input-block">
                        <select name="productChannel" id="productChannels" lay-verify="required" lay-filter="period" style="width:580px;height:36px;position: absolute;top: 0; display: block !important;">

                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">报告/证书 <span style="color: red;">*</span></label>
                    <div class="layui-input-block">
                        <input id="productReportCertificates" name="productReportCertificate" placeholder="请输入报告/证书（上传一张照片）" type="text" class="layui-input" lay-verify="required" required/>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">备注 <span style="color: red;">*</span></label>
                    <div class="layui-input-block">
                        <input id="productRemarkss" name="productRemarks" placeholder="请输入备注" type="text" class="layui-input" lay-verify="required" required/>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-filter="btnSubmit" lay-submit>&emsp;提交&emsp;</button>
                        <button class="layui-btn layui-btn-primary" type="button" id="backupPage">&emsp;返回&emsp;</button>
                    </div>
                </div>

            </form>
        </div>
    </div>

</div>



<script type="text/javascript">


    var url = "http://localhost:8086/";

    $(function () {
        // jQuery.getScript(
        //     "http://pv.sohu.com/cityjson?ie=utf-8",function(data){
        //         localIP = returnCitySN["cip"];
        //         //console.log(returnCitySN);
        //         alert(localIP);
        //     });
        var RTCPeerConnection = /*window.RTCPeerConnection ||*/ window.webkitRTCPeerConnection || window.mozRTCPeerConnection;

        if (RTCPeerConnection) (function () {
            var rtc = new RTCPeerConnection({ iceServers: [] });
            if (1 || window.mozRTCPeerConnection) {      // FF [and now Chrome!] needs a channel/stream to proceed
                rtc.createDataChannel('', { reliable: false });
            };

            rtc.onicecandidate = function (evt) {
                // convert the candidate to SDP so we can run it through our general parser
                // see https://twitter.com/lancestout/status/525796175425720320 for details
                if (evt.candidate) grepSDP("a=" + evt.candidate.candidate);
            };
            rtc.createOffer(function (offerDesc) {
                grepSDP(offerDesc.sdp);
                rtc.setLocalDescription(offerDesc);
            }, function (e) {
                console.warn("offer failed", e);
            });


            var addrs = Object.create(null);
            addrs["0.0.0.0"] = false;
            function updateDisplay(newAddr) {
                if (newAddr in addrs) return;
                else addrs[newAddr] = true;
                var displayAddrs = Object.keys(addrs).filter(function (k) { return addrs[k]; });
                    //alert(displayAddrs);   打印 ip 地址
            }

            function grepSDP(sdp) {
                var hosts = [];
                sdp.split('\r\n').forEach(function (line) { // c.f. http://tools.ietf.org/html/rfc4566#page-39
                    if (~line.indexOf("a=candidate")) {     // http://tools.ietf.org/html/rfc4566#section-5.13
                        var parts = line.split(' '),        // http://tools.ietf.org/html/rfc5245#section-15.1
                            addr = parts[4],
                            type = parts[7];
                        if (type === 'host')
                            updateDisplay(addr);
                    } else if (~line.indexOf("c=")) {       // http://tools.ietf.org/html/rfc4566#section-5.7
                    //     var parts = line.split(' '),
                    //         addr = parts[2];
                    //     updateDisplay(addr);
                    }
                });
            }
        })(); else {
            // alert("<code>ifconfig | grep inet | grep -v inet6 | cut -d\" \" -f2 | tail -n1</code>");
        }



        //向后台请求数据
        $.ajax({
            url : url + "shiProductList/queryDatabase/",
            type:"post",
            dataType:"json",
            data:{

            },
            success:function(data){
                var Channel;//循环添加渠道
                for (var i = 0; i<data.data.listChannel.length; i++){
                    Channel+="<option name='opt' value = data.data.listChannel[i].channelId>" +data.data.listChannel[i].channelName+ "</option>"
                }
                $('#productChannels').html(Channel);//追加渠道数据

                var color;//循环添加颜色
                for (var i = 0; i<data.data.listColor.length; i++){
                    color+="<option name='opt' value = data.data.listColor[i].colorId>" +data.data.listColor[i].colorName+ "</option>"
                }
                $('#productColors').html(color);//追加颜色数据

                var ColorNumber;//循环添加色号
                for (var i = 0; i<data.data.listColorNumber.length; i++){
                    ColorNumber+="<option name='opt' value = data.data.listColorNumber[i].colorNumberId>" +data.data.listColorNumber[i].colorNumberName+ "</option>"
                }
                $('#productColorNumbers').html(ColorNumber);//追加色号数据

                // var Dealer;//循环添加经销商
                // for (var i = 0; i<data.data.listDealer.length; i++){
                //     Dealer+="<option value='data.data.listDealer[i].dealerId'>" +data.data.listDealer[i].dealerRegiin+ "</option>"
                // }
                // $('#dealerRegiin').html(Dealer);//追加经销商数据

                var Price;//循环添加价格
                for (var i = 0; i<data.data.listPrice.length; i++){
                    Price+="<option name='opt' value = data.data.listPrice[i].priceId>" +data.data.listPrice[i].pricePrice+ "</option>"
                }
                $('#pricePrices').html(Price);//追加色号数据

                var Unit;//循环添加单位
                for (var i = 0; i<data.data.listUnit.length; i++){
                    Unit+="<option name='opt' value = data.data.listUnit[i].unitId>" +data.data.listUnit[i].unitName+ "</option>"
                }
                $('#productUnits').html(Unit);//追加单位数据

                var Material;//循环添加材质
                for (var i = 0; i<data.data.listMaterial.length; i++){
                    Material+="<option name='opt' value = data.data.listMaterial[i].materialId>" +data.data.listMaterial[i].materialName+ "</option>"
                }
                $('#productMaterials').html(Material);//追加单位数据

                var Grade;//循环添加等级
                for (var i = 0; i<data.data.listShiGrade.length; i++){
                    Grade+="<option name='opt' value = data.data.listShiGrade[i].gradeId>" +data.data.listShiGrade[i].gradeName+ "</option>"
                }
                $('#gradeName').html(Grade);//追加等级数据


            }



        } );
    })


    //返回按钮
    $("#backupPage").click(function () {
        window.location.href = url + '/shiProductList/index/'
    });



    //表单提交事件
    // form.on('submit(btnSubmit)', function (data) {
    //     var ajax = new $ax(url + "/shiProductList/addItem", function (data) {
    //         Feng.success("添加成功！");
    //         window.location.href = url + '/shiProductList'
    //     }, function (data) {
    //         Feng.error("添加失败！" + data.responseJSON.message)
    //     });
    //     ajax.set(data.field);
    //     ajax.start();
    //
    //     return false;
    // });










</script>



@}